home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / dll_gen / drvplus / chgvname.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-07-22  |  3.9 KB  |  133 lines

  1. VERSION 2.00
  2. Begin Form ChgVname 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Change Volume Name"
  6.    ClientHeight    =   2400
  7.    ClientLeft      =   1095
  8.    ClientTop       =   1485
  9.    ClientWidth     =   3615
  10.    ControlBox      =   0   'False
  11.    Height          =   2805
  12.    Left            =   1035
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2400
  17.    ScaleWidth      =   3615
  18.    Top             =   1140
  19.    Width           =   3735
  20.    Begin TextBox Text1 
  21.       Height          =   285
  22.       Left            =   240
  23.       MaxLength       =   11
  24.       TabIndex        =   0
  25.       Text            =   "Text1"
  26.       Top             =   1200
  27.       Width           =   3135
  28.    End
  29.    Begin DriveListBox Drive1 
  30.       Height          =   315
  31.       Left            =   240
  32.       TabIndex        =   3
  33.       Top             =   240
  34.       Width           =   3135
  35.    End
  36.    Begin CommandButton CmdOkay 
  37.       BackColor       =   &H00C0C0C0&
  38.       Cancel          =   -1  'True
  39.       Caption         =   "O &K A Y"
  40.       Height          =   375
  41.       Left            =   1800
  42.       TabIndex        =   2
  43.       Top             =   1800
  44.       Width           =   1575
  45.    End
  46.    Begin CommandButton CmdChgName 
  47.       BackColor       =   &H00C0C0C0&
  48.       Caption         =   "Change &Name"
  49.       Default         =   -1  'True
  50.       Height          =   375
  51.       Left            =   240
  52.       TabIndex        =   1
  53.       Top             =   1800
  54.       Width           =   1575
  55.    End
  56. Dim VolName As String
  57. Sub CmdChgName_Click ()
  58.     Screen.MousePointer = 11
  59.     NewVolName$ = Text1.Text
  60.     If Len(NewVolName$) > 8 Then
  61.         x% = Len(NewVolName$)
  62.         TempName = Left$(NewVolName$, 8) + "." + Right$(NewVolName$, x% - 8)
  63.         NewVolName$ = TempName
  64.         End If
  65.     If NewVolName$ = "No Label" Then NewVolName$ = ""
  66.     NowDrive% = Asc(Left$(UCase$(Drive1.Drive), 1)) - 64
  67.     worked% = SetVolName(NowDrive%, NewVolName$)
  68.     Screen.MousePointer = 0
  69.     If worked% = False And NewVolName$ <> "" Then
  70.         MsgBox "Unable to rename volume!", 16, "Drive Error"
  71.         Exit Sub
  72.         End If
  73.     FormPassString = "NewVol"
  74.     Unload Me
  75. End Sub
  76. Sub CmdOkay_Click ()
  77.     FormPassString = "Okay"
  78.     Unload Me
  79. End Sub
  80. Sub Drive1_Change ()
  81.     Screen.MousePointer = 11
  82.     DriveLabel$ = UCase$(Drive1.Drive)
  83.     DriveNbr% = Asc(DriveLabel$) - 64
  84.     x& = GetDriveSize(DriveNbr%)
  85.     Screen.MousePointer = 0
  86.     If x& = 0 Then
  87.         MsgBox "Unavailable drive!", 16, "Drive Error " + DriveLabel$
  88.         drv% = GetDefaultDrive()
  89.         Drive1.Drive = UCase$(Chr$(drv% + 64))
  90.         End If
  91.     GetVolName
  92.     Text1.Text = VolName$
  93.     Text1.SetFocus
  94. End Sub
  95. Sub Form_Load ()
  96.     FormCenterForm Me, DemoMain
  97.     GetVolName
  98.     Text1.Text = VolName$
  99.     Screen.MousePointer = 0
  100. End Sub
  101. Sub Form_Paint ()
  102.     DoForm3D Me, sunken, 3, 0
  103.     DoForm3D Me, raised, 1, 3
  104. End Sub
  105. Sub GetVolName ()
  106.     DriveLabel$ = Left$(UCase$(Drive1.Drive), 2)
  107.     FileSpec$ = DriveLabel$ + "\*.*"
  108.     FoundIt$ = Dir$(FileSpec$, 8)
  109.     If FoundIt$ = "" Then FoundIt$ = "No Label"
  110.     If Len(FoundIt$) > 8 Then
  111.         FoundIt$ = Strip(FoundIt$, ".")
  112.         End If
  113.     VolName$ = FoundIt$
  114. End Sub
  115. Sub Text1_GotFocus ()
  116.     Text1.SelStart = 0
  117.     Text1.SelLength = Len(Text1.Text)
  118. End Sub
  119. Sub Text1_KeyPress (KeyAscii As Integer)
  120.     Char = Chr(KeyAscii)
  121.     KeyAscii = Asc(UCase(Char))
  122.     If Char = Chr$(8) Then Exit Sub
  123.     If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then Exit Sub
  124.     If KeyAscii = Asc(" ") Then Exit Sub
  125.     If KeyAscii = Asc("*") Then Exit Sub
  126.     If KeyAscii = Asc("$") Then Exit Sub
  127.     If KeyAscii = Asc("!") Then Exit Sub
  128.     If KeyAscii < Asc("A") Or KeyAscii > Asc("Z") Then
  129.         KeyAscii = 0
  130.         Exit Sub
  131.         End If
  132. End Sub
  133.